package com.itany.corejava.day14;

import java.io.*;

public class TestBuffer {

    public static void main(String[] args) {


//        BufferedReader br=null;
//        PrintWriter pw=null;
//
//        try{
//
//            br=new BufferedReader(
//                    new InputStreamReader(
//                            new FileInputStream("d:/a.txt"),"utf-8")
//            );
//
//            pw=new PrintWriter("d:/b.txt","utf-8");
//
////            pw=new PrintWriter(
////                    new OutputStreamWriter(
////                            new FileOutputStream("d:/b.txt"),"utf-8"));
//
//
//            String s;
//
//            while((s=br.readLine())!=null){
//                System.out.println(s);
//                pw.println(s);
////                pw.flush();
//            }
//
//
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }finally{
//            if(pw!=null){
//                pw.close();
//            }
//            if(br!=null){
//                try {
//                    br.close();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//        }





        try(BufferedReader br=new BufferedReader(
                new InputStreamReader(
                        new FileInputStream("d:/a.txt"),"utf-8"));
            PrintWriter pw=new PrintWriter("d:/b.txt","utf-8")
           ){




            String s;

            while((s=br.readLine())!=null){
                System.out.println(s);
                pw.println(s);
//                pw.flush();
            }



        }catch (Exception e){
            e.printStackTrace();
        }
    }


}
